package com.chapter4.graph.mst;

import org.junit.Test;

import com.chapter1.basic.queue.Queue;
import com.util.Constants;
import com.util.In;

/**
 * 
* @ClassName: TestMST 
* @Description: mst测试类 
* @author minjun
* @date 2015年3月7日 上午12:50:13 
*
 */
public class TestMST {

	@Test
	public void testEdge(){
		Edge edge=new Edge(1, 3, 2.4);
		System.out.println(edge.either());
		System.out.println(edge.other(3));
		System.out.println(edge);
	}
	
	@Test
	public void testKruskalMST(){
		In in=new In(Constants.dirPath+"tinyEWG.txt");
		WeightEdgeGraph g=new WeightEdgeGraph(in);
		KruskalMST m=new KruskalMST(g);
		for(Edge e:m.edges()){
			System.out.println(e);
		}
		System.out.println(m.weight());
	}
	
	@Test
	public void testLazyPrimMST(){
		In in=new In(Constants.dirPath+"tinyEWG.txt");
		WeightEdgeGraph g=new WeightEdgeGraph(in);
		LazyPrimMST m=new LazyPrimMST(g);
		for(Edge e:m.edges()){
			System.out.println(e);
		}
		System.out.println(m.weight());
	}
	
	@Test
	public void testEagerPrimMST(){
		In in=new In(Constants.dirPath+"tinyEWG.txt");
		WeightEdgeGraph g=new WeightEdgeGraph(in);
		EagerPrimMST m=new EagerPrimMST(g);
		for(Edge e:m.edges()){
			System.out.println(e);
		}
		System.out.println(m.weight());
	}
	
	@Test
	public void testMyQ(){
		Queue<Integer> queue=new Queue<Integer>();
		queue.offer(3);
		queue.offer(1);
		queue.offer(2);
		queue.offer(4);
		
		for(int s:queue){
			System.out.println(s);
		}
		System.out.println("-------------");
		for(int s:queue){
			System.out.println(s);
		}
	}
	
	@Test
	public void testWEG(){
		In in=new In(Constants.dirPath+"tinyEWG.txt");
		WeightEdgeGraph g=new WeightEdgeGraph(in);
		int i=0;
		for(Edge e:g.edges()){
			i++;
			System.out.println(e);
		}
		System.out.println(i);
	}
}
